﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// 管理所有的战斗UI
class FightUIMgr : Singleton<FightUIMgr>
{
    CtrlBtn _ctrlBtn; // 控制按钮

    DistanceUI _disUI; // 奔跑距离

    public FightUIMgr()
    {
        GameMgr.Instance.FixedUpdateCallback += Loop;
    }

    public void Init()
    {
        if (_ctrlBtn == null) { _ctrlBtn = new CtrlBtn(); }
        if (_disUI == null) { _disUI = new DistanceUI(); }
    }

    // 控制按钮的消息响应
    public void SetBtn(Action<PointerEventData> btnDownDown, Action<PointerEventData> btnDownUp, Action<PointerEventData> btnJumpDown, Action<PointerEventData> btnJumpUp)
    {
        if (_ctrlBtn == null) { return; }

        _ctrlBtn.SetBtn(btnDownDown, btnDownUp, btnJumpDown, btnJumpUp);
    }

    internal void Reset()
    {
        if (_ctrlBtn != null)
        {
            _ctrlBtn.SetBtn(null, null, null, null);
        }
    }

    // 设置奔跑距离
    public void SetDistance(int v)
    {
        if (_disUI == null) { return; }

        _disUI.Dis = v;
    }

    private void Loop()
    {
    }

}
